package com.j283_5.wisdom_park.controller.peree_management;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.j283_5.wisdom_park.common.result.ResultData;
import com.j283_5.wisdom_park.pojo.*;
import com.j283_5.wisdom_park.service.PereeService;
import com.j283_5.wisdom_park.vo.tenant_management.*;
import com.j283_5.wisdom_park.vo.contract_management.CollectionRecordVo;
import com.j283_5.wisdom_park.vo.contract_management.ContractTableVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 租户信息管理
 * </p>
 *
 * @author laoda
 * @since 2022-04-28
 */

@RestController
@RequestMapping("/peree_Comments")
@Api(value = "租户信息管理",tags = "租户信息管理",produces="冯弋舟")
public class Peree_CommentsController {


    @Resource
    private PereeService service;

    /**
     * 多条件租户信息
     * @return
     */
    @RequestMapping(value = "/findPeree_Comments" , method = RequestMethod.GET)
    @ApiOperation(value = "多条件租户信息",notes = "多条件租户信息（分页）",produces="冯弋舟", response = ResultData.class)
    public ResultData findPeree_Comments(@Param("page") Page<Visitors> page, @Param("pereeCommentsVo") Peree_CommentsVo pereeCommentsVo){
        Map<String, Object> map = service.findPeree_CommentsVo(pereeCommentsVo, (int) page.getCurrent(), (int) page.getSize());
        return ResultData.ok().data(map);
    }

    /**
     * 根据id查询租户（企业详情）
     */
    @RequestMapping(value = "/findPeree_CommentsById" , method = RequestMethod.POST)
    @ApiOperation(value = "根据id查询租户",notes = "根据id查询租户",produces="冯弋舟", response = ResultData.class)
    public ResultData findPeree_CommentsById(Integer perId ){

        return service.findPereeInfoById(perId);
    }

    /**
     * 根据租户id查询人员信息
     */
    @RequestMapping(value = "/findPersonByPerId" , method = RequestMethod.POST)
    @ApiOperation(value = "根据租户id查询人员信息",notes = "根据租户id查询人员信息",produces="冯弋舟", response = ResultData.class)
    public ResultData findPersonByPerId(Page<Visitors> page,Person person){
        Map<String, Object> map = service.findPersonByPerId(person, (int) page.getCurrent(), (int) page.getSize());

        return ResultData.ok().data(map);
    }

    /**
     * 查询合同
     */
    @RequestMapping(value = "/findContract_Table" , method = RequestMethod.POST)
    @ApiOperation(value = "查询合同",notes = "查询合同",produces="冯弋舟", response = ResultData.class)
    public ResultData findContract(Integer perId){
        List<ContractTableVo> pereeContract = service.findPereeContract(perId);
        List<ContractTableVo> pereeRoom = service.findPereeRoom(perId);
        List<CollectionRecordVo> collectionByPereeId = service.findCollectionByPereeId(perId);
        Map<String,Object> map=new HashMap<>();
        map.put("pereeContract",pereeContract);
        map.put("pereeRoom",pereeRoom);
        map.put("collectionByPereeId",collectionByPereeId);
        return ResultData.ok().data(map);
//        return ResultData.ok();
    }

    /**
     * 进入租户人员新增界面
     * @return
     */
    @RequestMapping(value = "/insertPeree_TenInterface" , method = RequestMethod.POST)
    @ApiOperation(value = "进入租户人员新增界面",notes = "进入租户人员新增界面",produces="冯弋舟", response = ResultData.class)
    public ResultData insertPeree_TenInterface(){
          return   service.findtenNo();
    }

    /**
     * 进入租户信息新增界面
     * @return
     */
    @RequestMapping(value = "/insertPereeCommentsInterface" , method = RequestMethod.POST)
    @ApiOperation(value = "进入租户信息新增界面",notes = "进入租户信息新增界面",produces="冯弋舟", response = ResultData.class)
    public ResultData insertPereeCommentsInterface(){
        return   service.findPereeRoomTenVo();
    }

    /**
     * 租户新增
     */
    @RequestMapping(value = "/insertPeree" , method = RequestMethod.GET)
    @ApiOperation(value = "租户新增",notes = "租户新增",produces="冯弋舟", response = ResultData.class)
    public ResultData insertPeree(InsertPereeVo insertPereeVo){
     return    service.insertPereePerson(insertPereeVo);

    }

    /**
     * 人员删除
     * @return
     */
    @RequestMapping(value = "/DeletePersonInfo" , method = RequestMethod.POST)
    @ApiOperation(value = "人员删除",notes = "人员删除",produces="冯弋舟", response = ResultData.class)
    public ResultData DeletePersonInfo(@RequestBody List<Integer> personIdList){
       return service.DeletePereePerson(personIdList);


    }

    /**
     * 租户删除
     * @return
     */
    @RequestMapping(value = "/DeletePeree" , method = RequestMethod.POST)
    @ApiOperation(value = "租户删除",notes = "租户删除",produces="冯弋舟", response = ResultData.class)
    public ResultData DeletePeree(@RequestBody List<Integer> perIdList){
       return service.DeletePeree(perIdList);

    }


}


